package com.aaa.controller.sas;


import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.sas.RecordMsg;
import com.aaa.entity.sas.StatisticsMsg;
import com.aaa.entity.sas.TSasRecord;
import com.aaa.service.sas.TSasRecordService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * (TSasRecord)表控制层
 *
 * @author makejava
 * @since 2022-11-04 01:15:38
 */
@RestController
@RequestMapping("tSasRecord")
public class TSasRecordController {
    /**
     * 服务对象
     */
    @Autowired
    private TSasRecordService tSasRecordService;

    /*
        登录前检查手机号是否已经存在
     */
    @GetMapping("checkTel")
    public LayData checkTel(TSasRecord tSasRecord){
        System.out.println("tSasRecord = " + tSasRecord);
        Boolean i = tSasRecordService.checkTel(tSasRecord);
        return new LayData(i);
    }

    /*
        添加记录
     */
    @PostMapping("addRecord")
    public LayData addRecord(TSasRecord tSasRecord){
        int id = tSasRecordService.addRecord(tSasRecord);
        return new LayData(id);
    }

    /*
        查询所有的做题记录
     */
    @GetMapping("queryAll")
    public LayData queryAll(MyPage page, RecordMsg recordMsg){
        PageInfo pageInfo = tSasRecordService.queryAll(page,recordMsg);
        return new LayData(pageInfo);
    }

    /*
        根据id删除做题记录
     */
    @DeleteMapping("delRecord/{id}")
    public LayData delRecord(@PathVariable Integer id){
        Boolean i = tSasRecordService.delRecord(id);
        return new LayData(i);
    }

    /*
       查看详情
    */
    @GetMapping("{id}")
    public LayData queryDetails(@PathVariable Integer id,MyPage page){
        PageInfo pageInfo = tSasRecordService.queryDetails(page,id);
        return new LayData(pageInfo);
    }

    /*
        统计表中的信息
     */
    @RequestMapping("statistics")
    public LayData statistics(MyPage page, StatisticsMsg statisticsMsg){
        PageInfo pageInfo = tSasRecordService.statistics(page,statisticsMsg);
        return new LayData(pageInfo);
    }

    /*
        统计表中的信息(为了完成图形数据填充)
     */
    @GetMapping("statisticsTu")
    public LayData statisticsTu(MyPage page){
        PageInfo pageInfo = tSasRecordService.statisticsTu(page);
        return new LayData(pageInfo);
    }
}
